1. Field of the Invention
The present invention relates to an apparatus and method for numeric-to-string conversion. More particularly, the present invention relates to an apparatus and method for converting a digital computer representation of a number from a numeric representation to a string (or text) representation.
2. Description of Related Art
As used herein, the "data" means a representation of facts, concepts or instructions in a formalized manner suitable for communication, interpretation, or processing by human or automatic means. Also, as used herein, "computer" includes a device capable of performing the functions of a Turing Machine, including a microcomputer, minicomputer, or mainframe computer. A Turing Machine is a well-known computer science concept and is explained in Encyclopedia of Computer Science, Ed. Anthony Ralston, ISBN 0-88405-321-0 ("the Ralston text"), which is specifically incorporated herein by reference. "Memory" includes one or more devices for storing data for use by a computer, including electronic, magnetic, and electro-magnetic memory.
Various data representations are used in connection with digital computers in order to manipulate information. Different representations are used depending upon the objective. For example, some representations are better suited for performing arithmetic operations (e.g., adding, subtracting, multiplying), while others may be particularly suited for text processing (e.g., word processing). The choice of representation is typically of no direct concern to an end user of a computer or computer program, however it is nevertheless important since it may profoundly affect the efficiency of a system. Data representations and operations thereon are discussed in The Art of Computer Programming, D. E. Knuth, vols. 1-3, Addison-Wesley, which is specifically incorporated herein by reference.
Often, information must be converted from one data representation to another. The results of arithmetic operations performed on numeric representations of data, for example, may need to be displayed to an end user as text on a display. The present invention relates to such conversions. The invention is of particular importance with respect to converting floating point numbers into string representations.
In general, a floating point number, FP, is represented in binary notation in two parts: a mantissa (or significand), M, and an exponent, E, where FP=M.times.2.sup.E. Typically, the leftmost bit of each part denotes the sign, where "0" denotes a positive number and "1" denotes a negative number. Leading zeros in the mantissa are omitted in order to provide the maximum number of significant digits. The number of bits used to represent FP is a function of the width of the internal high-speed registers and buses for a particular computer. Numeric data representations, including floating point representations, are discussed more fully in the Ralston text.
A specific example of floating point representation is the IEEE 754 specification for the format of a long double number. 80 bits are used and are organized as shown below: ##STR1## where s=sign bit (0=positive, 1=negative),
i=position of the implicit "binary" point, PA1 1=integer bit of mantissa, and PA1 exponent bias=16,383 (3FFFH).
Strings, or text, on the other hand, are typically represented by a sequence of fixed length codes, where each code represents a particular character or symbol. American Standard Code for Information Interchange (ASCII) and Extended Binary-Coded Decimal Interchange Code (EBCDIC) are two well-known and widely used encoding schemes for character sets. Eight-bit codes are typically used in each coding scheme to represent individual characters. ASCII and EBCDIC are discussed more fully in the Ralston text.
A number of commercially available compilers contain numeric-to-string conversion facilities. MICROSOFT C, Version 6.0, IBM C Set/2, and BORLAND C++ compilers, in particular, use the "sprintf" library function to convert numbers to ASCII strings.